home *** CD-ROM | disk | FTP | other *** search
Text File | 1988-05-14 | 7.9 KB | 303 lines | [TEXT/TRUE] |
- ! Professor Mac Says…
- ! By David Kelly
- ! ©MacTutor, 1988
- ! With special thanks to Milton Bradley Co.
- ! For their "Simon" Game
-
- LIBRARY "Mactools*" ! MacStuff Library
- LIBRARY "PictLib*" ! PICTStuff Library
- DECLARE DEF MacGetFile$
- DIM notes(31)
- RANDOMIZE
- LET skilllevel=8 ! Set up levels
- LET level=1
- SET BACKGROUND COLOR 10 ! Get a Background color
- OPEN #1:screen .25,.67,.165,.75 ! open a section of screen
- WINDOW #1 ! and use it as a window
- SET WINDOW 0,1,0,1
- ASK SCREEN a,b,c,d
- CALL set_frame(a,b,c,d)
-
- LET filename$="Prof Says.PICT" ! Get the PICT resource
- IF filename$<>"" THEN
- CALL Read_pictfile(filename$,s$)
- CALL Draw_string(s$,1)
- ELSE
- PRINT "Prof Says.PICT file not found!"
- END IF
-
- ! Set up the main screen
- CALL SetRed
- FLOOD .3,.7 ! Fill the shape with Red
- CALL SetBlue
- FLOOD .7,.7 ! Fill the shape with Blue
- CALL SetGreen
- FLOOD .3,.3 ! Fill the shape with Green
- CALL SetYellow
- FLOOD .7,.3 ! Fill the shape with Yellow
- ! Turn off all shapes
- CALL darkred
- CALL darkblue
- CALL darkgreen
- CALL darkyellow
- ASK WINDOW a,b,c,d
- BOX KEEP a,b,c,d in None$ ! Save PICT so it can be restored later
- CALL MacTextFont(2) ! Get New York font
- SET TEXT JUSTIFY "center","half"
- DO ! Start the Main program loop
- SET COLOR MIX (0) rnd,rnd,rnd ! change the background color
- CALL SetButtons(level)
- DO
- LET Animationcount=Animationcount+1
- IF Animationcount>=500 then
- SET COLOR MIX (0) rnd,rnd,rnd ! change the background color
- LET Animationcount=0
- END IF
- GET MOUSE x,y,s ! Check for mouse press
- IF s>=1 then
- GET POINT x,y ! Get the mouse press
- LET result=0
- CALL PtInRect(x,y,.12,.295,.7,.8,result) ! Level 1
- IF result=1 then
- LET skilllevel=8
- LET level=1
- CALL SetStartGameButton(Level)
- END IF
- LET result=0
- CALL PtInRect(x,y,.32,.495,.7,.8,result) ! Level 2
- IF result=1 then
- LET skilllevel=14
- LET level=2
- CALL SetStartGameButton(Level)
- END IF
- LET result=0
- CALL PtInRect(x,y,.505,.680,.7,.8,result) ! Level 3
- IF result=1 then
- LET skilllevel=20
- LET level=3
- CALL SetStartGameButton(Level)
- END IF
- LET result=0
- CALL PtInRect(x,y,.705,.880,.7,.8,result) ! Level 4
- IF result=1 then
- LET skilllevel=31
- LET level=4
- CALL SetStartGameButton(Level)
- END IF
- LET result=0
- CALL PtInRect(x,y,.3,.7,.05,.15,result)
- IF result=1 then
- ! Quit Routine
- SET COLOR "White"
- BOX AREA 0,1,0,1
- SET COLOR "Black"
- BOX LINES 0,1,0,1
- SET COLOR "Blue"
- CALL MacTextSize(24)
- PLOT TEXT, AT .5,.6:"Thank you for"
- PLOT TEXT, AT .5,.4:"Reading MacTutor™"
- STOP
- END IF
- LET result=0
- CALL PtInRect(x,y,.3,.7,.2,.3,result)
- IF result=1 then
- ! Play the Game
- BOX SHOW none$ at 0,0
- LET x=0
- LET y=0
- LET numberofnotes=1
- LET tempo=100
- DO until numberofnotes=skilllevel
- CALL PlaySequence(numberofnotes,tempo,notes())
- FOR i=1 to numberofnotes
- SET COLOR MIX (0) rnd,rnd,rnd
- GET POINT x,y
- CALL buttonpress(x,y,selection)
- IF selection<>notes(i) then
- CALL MacSysBeep(500)
- CALL MacSysBeep(500)
- CALL MacSysBeep(500)
- EXIT DO
- END IF
- NEXT i
- LET numberofnotes=numberofnotes+1
- LET tempo=tempo+i*10
- PAUSE 1
- LOOP
- CALL SetButtons(level)
- END IF
- END IF
- LOOP
- LOOP
- END
-
- SUB SetButtons(GameLevel) ! Set Game Buttons
- CALL MacTextSize(14)
- SET COLOR "white"
- BOX AREA .3,.7,.05,.15 ! Quit Game Button
- BOX AREA .12,.295,.7,.8 ! Level 1 Button
- BOX AREA .32,.495,.7,.8 ! Level 2 Button
- BOX AREA .505,.680,.7,.8 ! Level 3 Button
- BOX AREA .705,.880,.7,.8 ! Level 4 Button
- SET COLOR "Black"
- BOX LINES .3,.7,.05,.15 ! Quit Game Button
- BOX LINES .12,.295,.7,.8 ! Level 1 Button
- BOX LINES .32,.495,.7,.8 ! Level 2 Button
- BOX LINES .505,.680,.7,.8 ! Level 3 Button
- BOX LINES .705,.880,.7,.8 ! Level 4 Button
- SET COLOR "Red"
- CALL SetStartGameButton(GameLevel)
- PLOT TEXT, AT .5,.11:"Quit Game"
- CALL MacTextSize(12)
- PLOT TEXT, AT .195,.77:"1"
- PLOT TEXT, AT .4,.77:"2"
- PLOT TEXT, AT .575,.77:"3"
- PLOT TEXT, AT .825,.77:"4"
- END SUB
-
- SUB SetStartGameButton(GameLevel) ! Set up the Start Game Button
- SET COLOR MIX (0) rnd,rnd,rnd
- CALL MacTextSize(14)
- SET COLOR "White"
- BOX AREA .1,.9,.2,.3 ! Start Game Button
- SET COLOR "Black"
- BOX LINES .1,.9,.2,.3 ! Start Game Button
- SET COLOR "Red"
- PLOT TEXT, AT .5,.26:"Start Game Level " & STR$(Gamelevel)
- END SUB
-
- SUB SetNone ! Display the PICT with colors off
- BOX SHOW None$ at 0,0
- END SUB
-
- SUB SetRed
- SET COLOR MIX (13) 1,0,0
- SET COLOR 13
- END SUB
-
- SUB DarkRed
- SET COLOR MIX (13) 0,0,0
- SET COLOR 13
- END SUB
-
- SUB SetGreen
- SET COLOR MIX (14) 0,1,0
- SET COLOR 14
- END SUB
-
- SUB DarkGreen
- SET COLOR MIX (14) 0,0,0
- SET COLOR 14
- END SUB
-
- SUB SetBlue
- SET COLOR MIX (15) 0,0,1
- SET COLOR 15
- END SUB
-
- SUB DarkBlue
- SET COLOR MIX (15) 0,0,0
- SET COLOR 15
- END SUB
-
- SUB SetYellow
- SET COLOR MIX (16) .9,1,0
- SET COLOR 16
- END SUB
-
- SUB DarkYellow
- SET COLOR MIX (16) 0,0,0
- SET COLOR 16
- END SUB
-
- SUB FlashRed
- SET COLOR MIX (13) 1,0,0
- LET note$="o5 mf ms c"
- PLAY note$
- PAUSE .5
- SET COLOR MIX (13) 0,0,0
- END SUB
-
- SUB FlashGreen
- SET COLOR MIX (14) 0,1,0
- LET note$="o5 mf ms a"
- PLAY note$
- PAUSE .5
- SET COLOR MIX (14) 0,0,0
- END SUB
-
- SUB FlashBlue
- SET COLOR MIX (15) 0,0,1
- LET note$="o5 mf ms >a"
- PLAY note$
- PAUSE .5
- SET COLOR MIX (15) 0,0,0
- END SUB
-
- SUB FlashYellow
- SET COLOR MIX (16) 1,1,0
- LET note$="o5 mf ms e"
- PLAY note$
- PAUSE .5
- SET COLOR MIX (16) 0,0,0
- END SUB
-
- SUB PtInRect(x,y,left,right,bottom,top,Result) ! See if point is in Rectangle
- IF x>left and x<right and y>bottom and y<top then
- LET Result=1
- ELSE
- LET Result=0
- END IF
- END SUB
-
- SUB Buttonpress(x,y,selection) ! Handle button press
- CALL PtInRect(x,y,0,.5,.5,1,result)
- IF result=1 then LET selectedcolor=13
- CALL PtInRect(x,y,0,.5,0,.5,result)
- IF result=1 then LET selectedcolor=14
- CALL PtInRect(x,y,.5,1,.5,1,result)
- IF result=1 then LET selectedcolor=15
- CALL PtInRect(x,y,.5,1,0,.5,result)
- IF result=1 then LET selectedcolor=16
- SELECT CASE selectedcolor
- CASE 13
- CALL flashred
- LET selection=1
- CASE 14
- CALL flashgreen
- LET selection=2
- CASE 15
- CALL flashblue
- LET selection=3
- CASE 16
- CALL flashyellow
- LET selection=4
- CASE ELSE
- LET selection=0
- END SELECT
- END SUB
-
- SUB PlaySequence(numberofnotes,tempo,notes()) ! Play the notes
- LET tempo$="t"&str$(tempo)
- PLAY tempo$
- FOR i=1 to numberofnotes
- SET COLOR MIX (0) rnd,rnd,rnd
- IF notes(i)=0 then
- LET note=int(4*rnd)+1
- ELSE
- LET note=notes(i)
- END IF
- SELECT CASE note
- CASE 1
- CALL flashred
- CASE 2
- CALL flashgreen
- CASE 3
- CALL flashblue
- CASE 4
- CALL flashyellow
- END SELECT
- LET notes(i)=note
- NEXT i
- END SUB
-